package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("wx/search")
public class SearchController {

    @Autowired
    SearchService searchService;

    @GetMapping("index")
    public BaseRespVo indexSearch(){
        Map<String,Object> map = searchService.indexSearch();
        return BaseRespVo.ok(map);
    }
    @GetMapping("helper")
    public BaseRespVo searchHelper(String keyword){
        List<String> list = searchService.searchHelper(keyword);
        return BaseRespVo.ok(list);
    }
    @PostMapping("clearhistory")
    public BaseRespVo clearHistory(){
        searchService.clearHistory();
        return BaseRespVo.ok();
    }
}
